#include "Protocol.hpp"
#include "ServerCal.hpp"
#include "TcpServer.hpp"
#include "log.hpp"
#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <string.h>

void Usage(std::string proc)
{
    std::cout << "\n\rUsage: " << proc << " port[1024+]\n" << std::endl;
}

std::string callback(const std::string& input)
{
    return input;
} 

int main(int argc, char *argv[])
{
    if(argc < 2|| argc > 2)
    {
        Usage(argv[0]);
        return 1;
    }
    else
    {
        uint16_t port = stoi(argv[1]);//服务端指定端口值
        ServerCal cal; // 创建计算器对象
        TcpServer *tsvp = new TcpServer(port, std::bind(&ServerCal::Calculator, &cal, std::placeholders::_1));
        tsvp->Init(); // 初始化服务器
        tsvp->Run(); // 启动服务器
    }

    return 0;
}